package updown.domain;

import lombok.Data;
import org.springframework.util.StringUtils;
import updown.util.DateUtils;

/**
 * <p>Title: updown.domain </p>
 * <p>Description:updown: - 定时任务 </p>
 *
 * @Author:jiangkaixin
 * @Date:1/5/2022
 * @Version: 1.0
 */
@Data
public class DownUpScheduleWrapper extends BaseEntity {
    private String startTime;
    private String endTime;
    private String spendTime;
    private String scheduleTime;
    private String localFilePath;
    private String jarVersionInfo;
    private String originalFileName;
    private String taskId;
    private String serviceName;
    private Boolean success = Boolean.FALSE;
    private Boolean done = Boolean.FALSE;
    private Integer timeToStart;

    public DownUpScheduleWrapper convert(DownUpSchedule downUpSchedule) {
        this.startTime = downUpSchedule.getStartTime();
        this.endTime = downUpSchedule.getEndTime();
        this.spendTime = downUpSchedule.getSpendTime();
        this.scheduleTime = downUpSchedule.getScheduleTime();
        this.localFilePath = downUpSchedule.getLocalFilePath();
        this.jarVersionInfo = downUpSchedule.getJarVersionInfo();
        this.originalFileName = downUpSchedule.getOriginalFileName();
        this.taskId = downUpSchedule.getTaskId();
        this.serviceName = downUpSchedule.getServiceName();
        this.success = downUpSchedule.getSuccess();
        this.done = downUpSchedule.getDone();
        if (!StringUtils.isEmpty(this.scheduleTime)) {
            try {
                this.timeToStart = DateUtils.getMinutesBetweenNoError(DateUtils.getCurDateTime(), this.scheduleTime);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return this;
    }
}
